package com.yoyo.itravel.dao;

import com.yoyo.itravel.bean.PlanType;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.List;

/**
 * 机型表相关操作接口【持久层】
 * @Author: liuchaojie
 * @Date 2020/6/17 14:17
 */
@Repository
public interface IPlanTypeDao {
    /**
     * 新增机型信息
     * @param planType
     * @return
     * @throws SQLException
     */
    @Insert("insert into tb_plan_type(planTypeId, name, size, imgUrl) values(#{planType.planTypeId},#{planType.name},#{planType.size},#{planType.imgUrl})")
    boolean addPlanType(@Param("planType") PlanType planType) throws SQLException;

    /**
     * 删除一条机型信息
     * @param planTypeId
     * @return
     * @throws SQLException
     */
    @Delete("delete from tb_plan_type where planTypeId=#{planTypeId}")
    boolean deleteByPlanType(String planTypeId) throws SQLException;

    /**
     * 查找所有机型信息
     * @return
     * @throws SQLException
     */
    @Select("select * from tb_plan_type")
    List<PlanType> selectAll() throws SQLException;

    /**
     * 修改根据机型Id机型信息
     * @param planType
     * @return
     * @throws SQLException
     */
    @Update("update tb_plan_type set name=#{planType.name} ,size=#{planType.size} ,imgUrl=#{planType.imgUrl} where planTypeId=#{planType.planTypeId}")
    boolean changePlanType(@Param("planType") PlanType planType) throws SQLException;
}
